package com.t235.gc.order.controller;

import com.t235.gc.AjaxResult;
import com.t235.gc.entity.GarbageRecyclingDetailOrder;
import com.t235.gc.order.service.GarbageRecyclingDetailOrderService;
import com.t235.gc.order.service.GarbageRecyclingOrderService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 垃圾回收详情订单表(GarbageRecyclingDetailOrder)表控制层
 *
 * @author makejava
 * @since 2021-03-24 08:45:29
 */
@Api
@RestController
@RequestMapping("garbageRecyclingDetailOrder")
public class GarbageRecyclingDetailOrderController {
    /**
     * 服务对象
     */
    @Resource
    private GarbageRecyclingDetailOrderService garbageRecyclingDetailOrderService;

    @Resource
    private GarbageRecyclingOrderService garbageRecyclingOrderService;

//    /**
//     * 通过主键查询单条数据
//     *
//     * @param id 主键
//     * @return 单条数据
//     */
//    @GetMapping("selectOne")
//    public GarbageRecyclingDetailOrder selectOne(Long id) {
//        return this.garbageRecyclingDetailOrderService.selectByPrimaryKey(id);
//    }

    //新增一个详细订单
    @RequestMapping("/insertGarbageRecyclingDetailOrder")
    public AjaxResult insertGarbageRecyclingDetailOrder(GarbageRecyclingDetailOrder garbageRecyclingDetailOrder){
        if(garbageRecyclingDetailOrderService.insertSelective(garbageRecyclingDetailOrder) > 0){
            garbageRecyclingOrderService.updateGarbageRecyclingOrder(garbageRecyclingDetailOrder.getOrderid(),garbageRecyclingDetailOrder.getRecyclingweight(),garbageRecyclingDetailOrder.getAccpoints());
        }
        return AjaxResult.success(garbageRecyclingDetailOrder);
    }

}
